package com.nondo.rdp.finance.domain;

import com.nondo.rdp.auth.domain.User;
import com.nondo.rdp.core.domain.attach.Attach;
import com.nondo.rdp.core.domain.base.BaseEntity;
import com.nondo.rdp.finance.config.DbConfig;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * 用户认证表
 *
 * @author ken
 * @version 2018-1-8
 */
@Entity
@Table(name = DbConfig.DEFAULT_TABLE_PREFIX + "user_auth")
public class UserAuth extends BaseEntity {
    public static interface Group1 {
    }//实名认证

    public static interface Group2 {
    }//达人认证

    public static interface Group3 {
    }//投顾认证

    public final static int PROGRESS_DEFAULT = 0;//未认证
    public final static int PROGRESS_AUDITING = 1;//审核中
    public final static int PROGRESS_PASS = 2;//审核通过
    public final static int PROGRESS_REFUSE = 3;//审核拒绝

    private Long id;        // 编号
    private User user;//对应用户信息
    private int type;//当前认证的类型，针对达人认证和投顾认证。0=达人认证，1=投顾认证
    private int identityAuth;//身份认证标示，0=未认证，1=审核中，2=审核通过，3=审核拒绝
    private int masterAuth;//达人认证标示，0=未认证，1=审核中，2=审核通过，3=审核拒绝
    private int adviserAuth;//投顾认证标示，0=未认证，1=审核中，2=审核通过，3=审核拒绝
    private String realname;// 真实姓名

    private String idCardNo;//身份证号码
    private Attach idCardFace;//身份证正面
    private Attach idCardBack;//身份证反面

    private String phone;//联系方式
    private String qq;//qq号码
    private String profession;//职业
    private String email;//邮箱
    private String company;//公司
    private String personalAdvantage;//个人优势
    private String investmentTime;//投资年限
    private String position;//岗位
    private String qualificationCertNo;//资格证号

    private Attach attachOne;//附件一
    private Attach attachTwo;//附件二
    private Attach attachThree;//附件三

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @OneToOne
    @JoinColumn(name = "uid")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Column(columnDefinition = "int default 0", nullable = false)
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Column(columnDefinition = "int default 0", nullable = false)
    public int getIdentityAuth() {
        return identityAuth;
    }

    public void setIdentityAuth(int identityAuth) {
        this.identityAuth = identityAuth;
    }

    @Column(columnDefinition = "int default 0", nullable = false)
    public int getMasterAuth() {
        return masterAuth;
    }

    public void setMasterAuth(int masterAuth) {
        this.masterAuth = masterAuth;
    }

    @Column(columnDefinition = "int default 0", nullable = false)
    public int getAdviserAuth() {
        return adviserAuth;
    }

    public void setAdviserAuth(int adviserAuth) {
        this.adviserAuth = adviserAuth;
    }

    @NotNull(groups = {Group2.class, Group3.class}, message = "必须填写真实姓名")
    @Size(min = 2, max = 10, groups = {Group2.class, Group3.class}, message = "请填写正确的真实姓名")
    @Column(name = "realname", length = 10)
    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    @NotNull(groups = {Group1.class, Group2.class, Group3.class}, message = "必须填写身份证号码")
    public String getIdCardNo() {
        return idCardNo;
    }

    public void setIdCardNo(String idCardNo) {
        this.idCardNo = idCardNo;
    }

    @NotNull(groups = Group1.class, message = "必须上传身份证正面")
    @OneToOne(cascade = CascadeType.ALL)//表示全级联关系
    @JoinColumn(name = "id_card_face", unique = true)
    public Attach getIdCardFace() {
        return idCardFace;
    }

    public void setIdCardFace(Attach idCardFace) {
        this.idCardFace = idCardFace;
    }

    @NotNull(groups = Group1.class, message = "必须上传身份证背面")
    @OneToOne(cascade = CascadeType.ALL)//表示全级联关系
    @JoinColumn(name = "id_card_back", unique = true)
    public Attach getIdCardBack() {
        return idCardBack;
    }

    public void setIdCardBack(Attach idCardBack) {
        this.idCardBack = idCardBack;
    }

    @NotNull(groups = {Group2.class, Group3.class}, message = "必须填写联系方式")
    @Size(min = 8, max = 15, groups = {Group2.class, Group3.class}, message = "请填写正确的联系方式")
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @NotNull(groups = {Group2.class, Group3.class}, message = "必须填写QQ号码")
    @Size(min = 6, max = 15, groups = {Group2.class, Group3.class}, message = "QQ号码在6到15位之间")
    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    @NotNull(groups = Group2.class, message = "必须填写职业")
    @Size(max = 20, groups = Group2.class, message = "职业长度在1到15位之间")
    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }

    @Size(max = 64, groups = {Group2.class, Group3.class}, message = "邮箱长度不超过64个字")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @NotNull(groups = Group3.class, message = "必须填写所在公司")
    @Size(max = 64, groups = {Group2.class, Group3.class}, message = "所在公司长度不超过64个字")
    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    @Size(max = 128, groups = Group2.class, message = "个人优势长度不超过128个字")
    public String getPersonalAdvantage() {
        return personalAdvantage;
    }

    public void setPersonalAdvantage(String personalAdvantage) {
        this.personalAdvantage = personalAdvantage;
    }

    @NotNull(groups = {Group2.class, Group3.class}, message = "必须选择投资年限或者从业年限")
    public String getInvestmentTime() {
        return investmentTime;
    }

    public void setInvestmentTime(String investmentTime) {
        this.investmentTime = investmentTime;
    }

    @NotNull(groups = Group3.class, message = "必须填写所在岗位")
    @Size(min = 1, max = 32, groups = Group3.class, message = "所在岗位长度为1到32个字")
    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    @NotNull(groups = Group3.class, message = "必须填写资格证号")
    @Size(min = 1, max = 64, groups = Group3.class, message = "资格证号长度为1到64个字")
    public String getQualificationCertNo() {
        return qualificationCertNo;
    }

    public void setQualificationCertNo(String qualificationCertNo) {
        this.qualificationCertNo = qualificationCertNo;
    }

    @NotNull(groups = {Group2.class}, message = "必须上传附件一")
    @OneToOne(cascade = CascadeType.ALL)//表示全级联关系
    @JoinColumn(name = "attach_one", unique = true)
    public Attach getAttachOne() {
        return attachOne;
    }

    public void setAttachOne(Attach attachOne) {
        this.attachOne = attachOne;
    }

    @OneToOne(cascade = CascadeType.ALL)//表示全级联关系
    @JoinColumn(name = "attach_two", unique = true)
    public Attach getAttachTwo() {
        return attachTwo;
    }

    public void setAttachTwo(Attach attachTwo) {
        this.attachTwo = attachTwo;
    }

    @OneToOne(cascade = CascadeType.ALL)//表示全级联关系
    @JoinColumn(name = "attach_three", unique = true)
    public Attach getAttachThree() {
        return attachThree;
    }

    public void setAttachThree(Attach attachThree) {
        this.attachThree = attachThree;
    }
}